package com.fypg.module.blooddonation.api.client.enums;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;

/**
 * 拒绝献血类型枚举
 * @author 盘古
 */
@Getter
@Schema(description = "拒绝献血类型枚举")
public enum RejectDonationTypeEnum {

    /**
     * 停止献血
     */
    @Schema(description = "停止献血")
    PERMANENT_STOP("YJHMD", "停止献血"),

    /**
     * 暂缓献血
     */
    @Schema(description = "暂缓献血")
    TEMPORARY_SUSPEND("ZHHMD", "暂缓"),

    /**
     * 间隔期不足
     */
    @Schema(description = "间隔期不足")
    INTERVAL_INSUFFICIENT("0000", "间隔期不足"),

    /**
     * 全年献血次数超量
     */
    @Schema(description = "全年献血次数超量")
    ANNUAL_COUNT_EXCEEDED("TOOMUCH", "全年献血次数超量"),

    /**
     * 全年献血量超量
     */
    @Schema(description = "全年献血量超量")
    ANNUAL_VOLUME_EXCEEDED("OVERVOL", "全年献血量超量");

    /**
     * 拒绝类型编码
     */
    private final String code;

    /**
     * 拒绝类型描述
     */
    private final String description;

    RejectDonationTypeEnum(String code, String description) {
        this.code = code;
        this.description = description;
    }

    /**
     * 根据编码获取枚举
     */
    public static RejectDonationTypeEnum getByCode(String code) {
        for (RejectDonationTypeEnum type : values()) {
            if (type.getCode().equals(code)) {
                return type;
            }
        }
        return null;
    }

    /**
     * 根据编码获取描述
     */
    public static String getDescriptionByCode(String code) {
        RejectDonationTypeEnum type = getByCode(code);
        return type != null ? type.getDescription() : "未知拒绝原因";
    }

    /**
     * 验证拒绝类型编码是否有效
     */
    public static boolean isValidCode(String code) {
        return getByCode(code) != null;
    }

    /**
     * 获取所有拒绝类型编码列表
     */
    public static java.util.List<String> getAllCodes() {
        return java.util.Arrays.stream(values())
                .map(RejectDonationTypeEnum::getCode)
                .collect(java.util.stream.Collectors.toList());
    }

    /**
     * 获取所有拒绝类型描述列表
     */
    public static java.util.List<String> getAllDescriptions() {
        return java.util.Arrays.stream(values())
                .map(RejectDonationTypeEnum::getDescription)
                .collect(java.util.stream.Collectors.toList());
    }

}
